import { getLogin } from '@/api/user'
import { getToken, setToken } from '@/utils/auth'
export default {
  namespaced: true,
  state: {
    token: getToken() || ''
  },
  mutations: {
    // 登录
    setToken(state, payload) {
      state.token = payload
      // 将存token
      setToken(payload)
    }

  },
  actions: {
    async login(context, payload) {
      // 登录接口
      const { data } = await getLogin(payload)
      // console.log('登录接口', data)
      context.commit('setToken', data.data.token.token)
    }
  }
}
